using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;

namespace CodeStory.WebControls
{
	public static class CodeStoryUtility
	{
		public static void RegisterFile(string configFileName, string res) {
			try {
				Assembly asm = typeof(DataSourceHelper).Assembly;
				Stream s = asm.GetManifestResourceStream(res);
				FileInfo fi = new FileInfo(configFileName);
				DirectoryInfo di = fi.Directory;
				if (!di.Exists) {
					di.Create();
				}
				FileStream fs = File.Open(configFileName, FileMode.Create);
				byte[] buffer = new byte[s.Length];
				s.Read(buffer, 0, buffer.Length);
				fs.Write(buffer, 0, buffer.Length);
				fs.Flush();
				fs.Close();
			} catch (FileNotFoundException) {
			} catch (NullReferenceException) {
			} catch {
			}
		}
	}
}
